// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db=cloud.database()
// 云函数入口函数
exports.main = async (event, context) => {
  
  const qyname= event.regis.qyname;
  const password = event.regis.password;
  const location = event.regis.location;
  const organ = event.regis.organ;
  const contact = event.regis.contact;
  const phone = event.regis.phone;
  const mail = event.regis.mail;
  const about = event.regis.about;
  const deadline = event.regis.deadline;
  const images = event.regis.images;


  const _id=event._id;
  await db.collection("regest_cache").doc(_id).remove()
  return await db.collection("regesters").add({
    data: {
      qyname: qyname,
      password: password,
      location: location,
      organ: organ,
      contact: contact,
      phone: phone,
      mail: mail,
      about: about,
      deadline: deadline,
      images: images
    }
  })
}